/**
 * @filename:TestServiceImpl 2022-9-21
 * @project Wonder Java前后台分离框架  1.1.0
 * Copyright(c) 2022 Wonder Co. Ltd. 
 * All right reserved. 
 */
package com.wonder.admin.service.impl;

import com.wonder.admin.domain.Test;
import com.wonder.admin.mapper.TestDao;
import com.wonder.admin.service.TestService;
import com.wonder.admin.request.TestRequest;
import com.wonder.common.utils.StringUtils;
import com.wonder.common.utils.MessageUtils;
import com.wonder.common.common.AjaxMap;
import java.util.Map;
import java.util.HashMap;
import java.util.List;

import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import java.util.Date;

/**   
 * @Description:TODO(测试模块服务实现)
 *
 * @version: 1.1.0
 * @author: Wonder
 * 
 */
@Service
public class TestServiceImpl  extends ServiceImpl<TestDao, Test> implements TestService  {

    /**
     * 验证测试模块信息
     * 
     * @param Test信息
     * @return 结果
     */
    @Override
    public String validate(Test test,String type){
    
    
       return "";
    }
    
    /**
	 * Description:测试模块分页返回
	 * @request:检索条件
	 * @page：分页参数
	 * @return:分页记录
	 */
	@Override 
	public IPage<Test> selectList(TestRequest request, Page<Test> page){
	    QueryWrapper<Test> queryWrapper = new QueryWrapper<>();
	    
        if (StringUtils.hasText(request.getTitle())) {
			    queryWrapper.like("title", request.getTitle()); 
		    } 
             
        if (request.getOper_time() != null){
        	Date[] oper_time=request.getOper_time();
        	if(oper_time.length>0)
        	  queryWrapper.ge("oper_time", oper_time[0]); 
        	if(oper_time.length==2)
        	  queryWrapper.le("oper_time",oper_time[1]);      
        	
        }    
             
    
	    if(StringUtils.hasText(request.getOrder()) && StringUtils.hasText(request.getSort())){
	        if(request.getOrder().equals("desc")) {
	        		queryWrapper.orderByDesc(request.getSort());
	        }else {
	        		queryWrapper.orderByAsc(request.getSort());
	        }
	    }else{
			queryWrapper.orderByDesc("id");	
		}    		
		Page<Test> selectPage = this.baseMapper.selectPage(page, queryWrapper);

		return selectPage;
      }
        
    
	
}